<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/mytag.jspf"%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>员工认证</title>
<script type="text/javascript">
//修改浏览器历史的url地址
if(window.location.href.indexOf('#forward')<0){
	window.history.replaceState('forward', null, window.location.href+'#forward');
}
else{
	window.location.href="${ctx}/weixin/employee/billing";
}
	
    $("#submit-btn").on("click",function(){
    	var username = $("#username").val();
        if (!username) {
        	Comm.msg("请输入账号");
            return;
        }
		var password = $("#password").val();
        if (!password) {
        	Comm.msg("请输入密码");
            return;
        }
		var $btn = $(this);
		$btn.attr("disabled","disabled").text("正在提交...");
		//$("form").submit();
		
		$.ajax({
			type : 'POST',
            url: "${ctx}/weixin/employee/login",
            dataType: "json",
            data:$('form').serialize(),
            success: function (data) {
            	$btn.prop("disabled",false).text("认证");
            	Comm.msg(data.msg);
                if (data.success) {
                	var backUrl = $('#backUrl').val();
                	if(backUrl==''||backUrl==null){
                		//window.location.href="${ctx}/weixin/employee/vipCard";
                	}else{
                		window.location.href=backUrl;
                	}
                }
            },
            error: function () {
            	Comm.msg("认证失败，请重试");
            	$btn.prop("disabled",false).text("认证");
            }
        });
	});
</script>
</head>
<body>
	<h2 class="app-title">请输入账号和密码</h2>
	<div class="am-g">
		<div class="am-u-sm-12 am-text-xs am-text-grey am-padding-left">
			提示：忘记账号密码请于门店管理员联系
		</div>
		<div class="am-u-sm-12 am-margin-top">
			<form class="am-form am-form-horizontal">
			<input type="hidden" name="backUrl" id="backUrl" value="${backUrl}">
				<div class="am-form-group">
					<label class="am-u-sm-3 am-form-label am-text-sm">账号</label>
					<div class="am-u-sm-8 am-u-end"><input id="username" name="username" type="text"></div>
				</div>
				<div class="am-form-group">
					<label class="am-u-sm-3 am-form-label am-text-sm">密码</label>
					<div class="am-u-sm-8 am-u-end"><input id="password" name="password" type="password"></div>
				</div>
				<div class="am-form-group">
					<div class="am-u-sm-12 am-text-center">
						<button id="submit-btn" class="am-btn am-btn-landiao am-radius am-padding-horizontal-lg" type="button">认证</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</body>
</html>
